<?php

$image_url = "";
if(isset($data->drillDiagrams[0])) {
    $image_url = "images/diagrams/".$data->drillDiagrams[0]->id.".".$data->drillDiagrams[0]->file_ext;
}
else if(isset($data->youtube_id)) {
    $image_url = "http://img.youtube.com/vi/".$data->youtube_id."/0.jpg";
}
else {
    $image_url = "images/no-image.png";
}

// Change behaviour according to the view
$current_view = Yii::app()->controller->getAction()->getId();
if($current_view=="list") {
    $link =  $this->createUrl('drill/show', array('id' => $data->id));
}

?>

<div class="drill-list-grid">
    <a class="drill-title" href="<?php echo $link ?>"><?php echo GxHtml::encode($data->name)?></a>
    <a href="<?php echo $link ?>"><img class="drill-thumb" src="<?php echo $image_url; ?>"></a>
    <p class="drill-category"><?php echo GxHtml::encode($data->category0->drill_section_id) ?> - <?php echo GxHtml::encode($data->category0) ?></p>
    <p class="drill-players"><span class="drill-label">Players Required: </span><?php echo $data->players; ?></p>
    <div class="clear"></div>
</div>